<?php
error_reporting(E_ALL);

class person{
	public function age(int $age) : string{
		return 'Age is ' . $age;
	}

	public function name(string $name) : string{
		return 'Name is ' . $name;
	}

	public function isAlive(bool $alive) : string{
		return ($alive) ? "Yes" : "No";
	}
}

$person = new person();

echo $person->name(11);
echo $person->age(30.5);
echo $person->isAlive(4);


class packet {

	public function packet(){
		echo 'i am just a normal class method';
	}

	public function __construct(){
		echo 'I am default construtor';
	}}

$packet = new packet();
$packet->packet();


$int1 = 1;
$int2 = 2;
$int3 = 1;
echo "\n";

echo $int1 <=> $int3;
echo $int1 <=> $int2;
echo $int2 <=> $int3;
echo "\n";


function normal_sort($a, $b) : int {
	if ($a == $b) 
		return 0;
	if ($a < $b)
		return -1;
	return 1;	
}

function space_sort($a, $b) : int {
	return $a <=> $b;
}

$normalArray = [1,34,56,67,98,45];
usort($normalArray, 'normal_sort');
foreach ($normalArray as $k => $v) {
	echo $k . ' => ' . $v . "\n";
}

$spaceArray = [1,34,56,67,98,45];
usort($spaceArray, 'space_sort');
foreach ($spaceArray as $k => $v) {
	echo $k . ' => ' . $v . "\n";
}


$name = $argv[1] ?? 'jean';
var_dump($name);


$first = ['name' => 'second'];
$second = 'Howdy';

echo ${$first['name']} . "\n";
